<template>

  <div class="common-layout">
    <el-container>
      <el-header>
        <span>username</span>
      </el-header>
      <el-container>

        <!-- 左边栏菜单 -->
        <el-aside width="200px">
          <el-menu
              class="el-menu-vertical-demo"
              default-active="2"
              active-text-color="#ffd04b"
              background-color="#545c64"
              text-color="#fff"
              @open="handleOpen"
              @close="handleClose"
              @select="handleLeftSelect"
            >
              <el-sub-menu index="1">
                <template #title>
                  <el-icon><location /></el-icon>
                  <span>商家管理</span>
                </template>
                <el-menu-item index="userlist">菜单1</el-menu-item>
                <el-menu-item index="shopperlist">菜单2</el-menu-item>
                <el-menu-item index="sytemlog">菜单3</el-menu-item>
              </el-sub-menu>

              <el-sub-menu index="2">
                <template #title>
                  <el-icon><icon-menu /></el-icon>
                  <span>商品管理</span>
                </template>
                <el-menu-item index="aaa">菜单4</el-menu-item>
                <el-menu-item index="bbb">菜单5</el-menu-item>
                <el-menu-item index="ccc">菜单6</el-menu-item>
              </el-sub-menu>

              <el-sub-menu index="3">
                <template #title>
                  <el-icon><setting /></el-icon>
                  <span>系统管理</span>
                </template>
                <el-menu-item index="ddd">菜单7</el-menu-item>
                <el-menu-item index="eee">菜单8</el-menu-item>
                <el-menu-item index="fff">菜单9</el-menu-item>
              </el-sub-menu>
              

            </el-menu>
        </el-aside>

        <!-- 右侧主页面 -->
        <el-main>
          <router-view/>
        </el-main>

      </el-container>
    </el-container>
  </div>

</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router';


const router = useRouter();

const activeIndex2 = ref('1')
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}

// 左侧菜单的点击事件
const handleLeftSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
  if(key == 'userlist') {
    //router.push('/home/userlist');
  }
  else if(key == 'shopperlist') {

  }
  else if(key == 'sytemlog') {
  }
}

const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}

// 页面加载钩子函数
onMounted(() => {
}) 
</script>

<style scoped>

</style>